import {
  Col,
  Row,
  Divider,
  Descriptions,
  Badge,
  Button,
  message,
  Spin,
} from 'antd';
import React, { useState } from 'react';
import request from '@/http';
import { Homework } from '@/pages/login/service';

export default function index() {
  const [data, setdata] = useState({
    createTime: '',
    title: '',
    teacherName: '',
    completeDate: '',
    appendsLink: '',
  }); //获取数据
  const getData = async () => {
    await request
      .post(
        (Homework.getHomeworkIds().role == 1
          ? '/student/Operation/StudentTask/'
          : '/teacher/Operation/PersonalTask/') + Homework.getHomeworkIds().id,
      )
      .then((response: any) => {
        setspinning(false);
        if (response.code == 200) {
          response.data == null ? '' : setdata(response.data);
        } else {
          message.error(response.message);
        }
      });
  };

  React.useEffect(() => {
    getData();
  }, []);

  const [spinning, setspinning] = useState(true);
  return (
    <>
      <Spin spinning={spinning} size="large">
        <Row justify="center">
          <Col span={22}>
            <p style={{ fontSize: 30, color: 'black' }}>{data.title}</p>
          </Col>
          <Col span={22}>
            <Descriptions title={'完成' + data.title + '，具体要求如下：'}>
              <Descriptions.Item>{data.appendsLink}</Descriptions.Item>
            </Descriptions>
          </Col>
          {/* <Col span={22}>
          <img src="#"></img>
          <img src="#"></img>
        </Col> */}
          <Divider />
          <Col span={22}>
            <h3>附件</h3>
            <Button type="link">XXXXXXX</Button>
          </Col>
          <Col span={22} style={{ marginTop: 20 }}>
            <Descriptions bordered>
              <Descriptions.Item label="发布人">
                {data.teacherName}
              </Descriptions.Item>
              <Descriptions.Item label="发布时间">
                {data.completeDate}
              </Descriptions.Item>
              <Descriptions.Item label="计划完成时间">
                {data.createTime}
              </Descriptions.Item>
            </Descriptions>
          </Col>
        </Row>
      </Spin>
    </>
  );
}
